# run.py
#!/usr/bin/env python3
"""
翁法罗斯平台 - 快速启动脚本
"""

import os
import sys
from pathlib import Path

# 添加项目根目录到Python路径
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))

def ensure_directories():
    """确保必要的目录存在"""
    directories = [
        "data/training",
        "data/models", 
        "data/game_state",
        "data/narrative",
        "logs",
        "visualizations",
        "reports",
        "tests"
    ]
    
    for directory in directories:
        Path(directory).mkdir(parents=True, exist_ok=True)
    
    print("目录结构已就绪")

def check_dependencies():
    """检查依赖"""
    try:
        import torch
        import fastapi
        import numpy
        import matplotlib
        print("核心依赖检查通过")
        return True
    except ImportError as e:
        print(f"依赖检查失败: {e}")
        print("请运行: pip install -r requirements.txt")
        return False

def main():
    """主启动函数"""
    print("=" * 50)
    print("翁法罗斯传奇十二因子平台")
    print("=" * 50)
    
    # 检查依赖
    if not check_dependencies():
        return
    
    # 确保目录
    ensure_directories()
    
    # 启动Web界面
    print("启动Web界面...")
    from web_interface.app import run_web_app
    run_web_app()

if __name__ == "__main__":
    main()